const promiseRace = (promises)=>{
    return new Promise((resolve,reject)=>{
        if(!Array.isArray(promises)){
            return new TypeError('params must be array')
        }
        promises.map(promise=>{
            promise.then(data=>{
                resolve(data);
            },err=>{
                reject(err)
            })
        })
    })
}

const p1  = ()=>{
    return new Promise((resolve,reject)=>{
        resolve(10)
    })
}
const p2  =  ()=>{
    return new Promise((resolve,reject)=>{
        resolve(20)
    })
}

promiseRace([p1(),p2()]).then(data=>{
    console.log(data)
},err=>{
    console.log(err)
})

